// Objetos svg como elmentos html.

function svgCanvas(name, id, height, width) {
	this.tag = document.getElementById(id);
	if (this.tag == undefined)
		this.tag = document.createElementNS('http://www.w3.org/2000/svg','svg');

	this.tag.setAttribute('name',name);
	this.tag.setAttribute('id',id);
	this.tag.setAttribute('version',1.1);
	this.tag.setAttribute('viewBox','0 0 15 15');
	if (height != undefined)
		this.tag.setAttribute('height',height);
	if (width != undefined)
		this.tag.setAttribute('width',width);	
};

svgCanvas.prototype.appendChild = function (e) {
	return this.tag.appendChild(e.getElement());
};

svgCanvas.prototype.getElement = function() {
	return this.tag;
};

function line(x1,y1,x2,y2, style) {
	this.tag = document.createElementNS('http://www.w3.org/2000/svg','line');

	this.tag.setAttribute('x1',x1);
	this.tag.setAttribute('y1',y1);
	this.tag.setAttribute('x2',x2);
	this.tag.setAttribute('y2',y2);
	this.tag.setAttribute('style',style);
};

line.prototype.getElement = function() {
	return this.tag;
};

function polyline(points, style) {
	this.tag = document.createElementNS('http://www.w3.org/2000/svg','polyline');

	var isX = true;
	var aux = "";
	for (var i=0; i<points.length; i++) {
		if (isX)
			aux = aux + " ";
		else
			aux = aux + ",";
		aux = aux + points[i].toString();
	}
	this.tag.setAttribute('points',aux);
	this.tag.setAttribute('style',style);
}

polyline.prototype.getElement = function() {
	return this.tag;
};

